<template>
  <tr >
    <td><input type="checkbox" @change="check" :checked="checked"/></td>
    <td>{{ name }}</td>
    <td>{{ price }}</td>
    <td>
      <button @click="del" :num='num'>-</button>
      {{ num }}
      <button @click="add" :num='num'>+</button>
    </td>
    <td>{{ allPrice }}</td>
    <td><button @click.prevent="remove">删除</button></td>
  </tr>
</template>

<script>
export default {
  props: ['name', 'price', 'num', 'checked'],
  methods: {
    del (num) {
      console.log(num)
    },
    add (num) {
      console.log(num)
    },
    remove () {
      this.$emit('removeGood', this.name)
    },
    check () {
      this.$emit('check', this.name, this.checked)
    }
  },
  computed: {
    allPrice () {
      // return console.log(this.price)
      const sum = this.price * this.num
      return sum
    }
  }
}
</script>

<style scoped>
.Goods {
  border: 1px solid black;
  text-align: center;
  float: right;
}
</style>
